#define  _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>
#include <math.h>

/*
int main()
{
	for(int i = 10000; i <100000; i++)
	{
		int count = 0;
		int sum = 0;
		int k = i;
		while (k)
		{
			count++;
			k = k / 10;
		}
		k = i;
		for (int i = 1; i < count; i++)
		{
			sum += (k / (int)(pow(10, i))) * (k % (int)(pow(10, i)));
		}
		if(sum == i)
			printf("%d ", i);
	}
	return 0;
}
*/


int main()
{
	int k = 0;
	int arr[50] = { 0 };
	int num = 0;

	int count = 0;
	scanf("%d", &k);
	for (int i = 0; i < k; i++)
	{
		scanf("%d", &arr[i]);
	}
	scanf("%d", &num);
	for (int i = 0; i < k; )
	{
		if (arr[i] == num)
		{
			for (int j = i; j < k - 1; j++)
			{
				arr[j] = arr[j + 1];
				arr[j + 1] = 0;
			}
			count++;
			continue;
		}
		i++;
	}
	for (int i = 0; i < k - count ; i++)
	{
		printf("%d ", arr[i]);
	}
	return 0;
}